define(['jquery', 'bootstrap', 'frontend', 'form', 'table', 'template'], function ($, undefined, Frontend, Form, Table, Template) {
    var validatoroptions = {
        invalid: function (form, errors) {
            $.each(errors, function (i, j) {
                Layer.msg(j);
            });
        }
    };
    var Controller = {
        index: function () {
            setInterval(function () {
                //window.location.reload();
            }, 1000);//1秒刷新一次

            Controller.api.bindevent();
        },
        command: function () {
            $(document).on("click", ".sendmsg[data-msgtype]", function () {

                console.log("click sendmsg");

                var url = 'taizhu/sendmsg';
                var msgtype = $(this).data('msgtype');
                var _this = $(this);
                Fast.api.ajax({
                    url: url,
                    data: {msgtype: msgtype, deviceid:Config.deviceid},
                }, function (data, ret) {
                    console.log(ret);
                });
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"), function (data, ret) {
                    //console.log(ret);
                    setTimeout(function () {
                        location.href = ret.url ? ret.url : "/";
                    }, 1000);
                });
            },
            formatter: {//渲染的方法
                zxstatus: function (value, row, index) {
                    //Controller.api.formatter.zxstatus
                    if (value == 0) {
                        return [
                            '<a href="javascript:;" class="bg-red-gradient"> 離線 </a>'
                        ].join("")

                    } else {
                        return [
                            '<a href="javascript:;" class="bg-green"> 在線 </a>'
                        ].join("")
                    }
                }
            }
        }
    };
    return Controller;
});